unit Constant;

interface
uses
  sysutils, windows, dialogs;
const
  Create_Tables_Str = 'create table tables  '
    + '(  '
    + '	id int identity(1,1) primary key,  '
    + '	seq  int not null,  '
    + '	name char(50) not null,  '
    + '	comments char(100), '
    + ' browsetype char(30) default ''dbgrid'', '
    + ' IdStr char(20) default ''id'','
    + ' NameStr char(20) default ''name'','
    + ' CodeStr char(20) default ''code'''
    + ')  ';
  Create_columns_Str = 'create table columns '
    + '(  '
    + '	id int identity(1,1) primary key,  '
    + ' corder int , '
    + '	table_id int references tables(id),  '
    + '	name char(30),  '
    + '	datatype char(20),  '
    + '	clength int,  '
    + '	cprecision int,  '
    + '	nn  bit default true,  '
    + ' un  bit default false, '
    + '	Ai  bit default false,  '
    + '	Pk  bit default false,  '
    + '	cdefault char(50),  '
    + '	showname char(50),  '
    + '	width    int default 60,  '
    + '	edittype char(20) default ''Edit'',  '
    + ' visible  bit default  true, '
    + '	comments char(100) , '
    + ' Editable bit default true,'
    + ' SourceTable char(40) ,'
    + ' SourceField char(40)'
    + ')  ';
  Create_indexes_Str = 'create table indexes  '
    + '(  '
    + '	id int identity(1,1) primary key,  '
    + '	table_id int references tables(id),  '
    + '	name  char(50),  '
    + ' IsCluster bit default false,' 
    + '	indextype  char(10),  '
    + '	column_id int ,  '
    + '	column_seq int,  '
    + '	corder int,  '
    + '	comments char(100)  '
    + ')  ';
  Create_frKeys_Str = 'create table frKeys  '
    + '(  '
    + '	id  int identity(1,1) primary key,  '
    + '	table_id int references tables(id),  '
    + '	name  char(50),  '
    + '	column_id int ,  '
    + '	refer_table_id int references tables(id),  '
    + '	refer_column_id int references columns(id),  '
    + '	comments char(100),  '
    + ' subtable bit default false '
    + ')  ';
  Create_systypesx_Str = 'create table systypesx  '
    + '(  '
    + 'xtype  int primary key,  '
    + 'name  char(50)  '
    + ')  ';
  Create_usertypes_Str = 'create table usertypes  '
    + '(  '
    + 'id        int identity(1,1) primary key,  '
    + 'name      char(50) ,  '
    + 'xtype     int   references systypesx(xtype),  '
    + 'tdefault  int       ,  '
    + 'allownulls bit default true       ,  '
    + 'prec      int  ,  '
    + 'scale     int  '
    + ')  ';
  Create_defaults_Str = 'create table defaults  '
    + '(  '
    + 'id int primary key,  '
    + 'name char(128),  '
    + 'dtext text  '
    + ')  ';
  Create_trigers_Str = 'create table trigers  '
    + '(  '
    + 'id int primary key,  '
    + 'name char(128),  '
    + 'table_id int references tables(id),  '
    + 'dtext text  '
    + ')  ';
  Create_views_Str = 'create table views  '
    + '(  '
    + 'id int  primary key,  '
    + 'name char(128),  '
    + 'dtext text  '
    + ')  ';
  Create_procedures_Str = 'create table procedures  '
    + '(  '
    + 'id int primary key,  '
    + 'name char(128),  '
    + 'dtext text  '
    + ')  ';
  Create_functions_Str = 'create table functions  '
    + '(  '
    + 'id int primary key,  '
    + 'name char(128),  '
    + 'dtext text  '
    + ')  ';

  Create_mydbproperty_Str = 'create table mydbproperty '
    + '(  '
    + 'id int identity(1,1) primary key,  '
    + 'dbname  char(50),'
    + 'dbtype  char(240),  '
    + 'initalsql text  '
    + ')  ';
  Create_InitialSql_Str = 'create table InitialSql '
    + '(  '
    + 'id int identity(1,1) primary key,  '
    + 'itemName  char(50),'
    + 'initalsql text  '
    + ')  ';


  CreateStrArray: array[1..13] of string = (Create_Tables_Str,
    Create_columns_Str, Create_indexes_Str,
    Create_frKeys_Str, Create_systypesx_Str, Create_usertypes_Str,
      Create_defaults_Str,
    Create_trigers_Str, Create_views_Str, Create_procedures_Str,Create_functions_Str,Create_mydbproperty_Str,Create_InitialSql_Str);
  CONST_Tablenumber = 12;

procedure ShowError(dwerr: DWORD);

implementation

procedure ShowError(dwerr: DWORD);
var
  lpErrMsg: integer;
  strErrMsg: string;
begin
  FormatMessage(
    FORMAT_MESSAGE_ALLOCATE_BUFFER or FORMAT_MESSAGE_FROM_SYSTEM,
    nil, dwErr,
    LANG_NEUTRAL,
    @lpErrMsg, 0, nil);
  strErrMsg := StrPas(PChar(lpErrMsg));
  LocalFree(lpErrMsg);
  ShowMessage(strErrMsg);
//  MyAssert(blResult,
//    Loadstr(moCannotGetCurrentUserName) + strErrMsg); // 151
end;
end.

